<?php
/**
 * 终端注册
 * 
 * 消息ID：0x0100
 * 
 */
namespace lttxws;

class JT808_0100 extends JT808{
	
	/**
	 * 终端注册消息体数据格式解析
	 * 
	 * @param $data array 16进制数组
	 * @param $index  数组索引13
	 * 
	 * @return int  返回数字代表报警信息
	 */
	public function encodeBody($data, $type = false) {

	    //省域 ID
	    $provinceArray = array_slice($data, 13, 2);
	    
	    //市县域ID
	    $cityArray = array_slice($data, 13, 2);
	    
	    //终端型号
	    $deviceTypeArray= array_slice($data, 22, 20);
	    $deviceType = $this->hexToStr(implode('',$deviceTypeArray));
	    
	    //终端ID
	    $deviceIdArray= array_slice($data, 42, 7);
	    $deviceId = $this->hexToStr(implode('',$deviceIdArray));
	    
	    //车牌颜色
	    $colorArray= array_slice($data, 49, 1);
	    
	    //车辆标识(去除最后的校验码和标识位 )
	    $carMarkArray= array_slice($data, 50, -2);
	    $carMark = $this->hexToStr(implode('',$carMarkArray));
	    
	    $result= ['provinceArray'=>$provinceArray,'cityArray'=>$cityArray,'deviceType'=>$deviceType,'deviceId'=>$deviceId,'colorArray'=>$colorArray,'carMark'=>$carMark];
	    
	    return $result;
	}
}
?>